package com.iflytek.universitymanagement.service.impl;

import com.iflytek.universitymanagement.domain.CounselingRecord;
import com.iflytek.universitymanagement.domain.Student;
import com.iflytek.universitymanagement.mapper.CounselingRecordMapper;
import com.iflytek.universitymanagement.mapper.StudentMapper;
import com.iflytek.universitymanagement.service.CounselingRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author louyp
 * @since 2024-11-26
 */
@Service
public class CounselingRecordServiceImpl extends ServiceImpl<CounselingRecordMapper, CounselingRecord> implements CounselingRecordService {
    @Resource
    CounselingRecordMapper counselingRecordMapper;

    @Resource
    StudentMapper studentMapper;

    public List<CounselingRecord> getAllCounselingRecordsWithStudentName() {
        List<CounselingRecord> records = counselingRecordMapper.selectAll();
        for (CounselingRecord record : records) {
            Student student = studentMapper.selectById(record.getStudentId());
            record.setStudent(student);
        }
        return records;
    }


}
